<template>
  <div v-text="value"></div>
</template>

<script>
export default {
  name: 'Telephone',
  props: {
    option: {
      type: Object,
      requried: false,
      default: () => {
        return {
          showMask: true
        };
      }
    },
    fieldValue: {
      type: String,
      required: false,
      default: () => {
        return undefined;
      }
    }
  },
  computed: {
    value() {
      const replaceLen = this.fieldValue.length - 7;
      let len = replaceLen;
      let replaceStr = '';
      while (len > 0) {
        replaceStr += '*';
        len--;
      }
      return this.option.showMask ? 
        this.fieldValue.substring(0, 3) + replaceStr + this.fieldValue.substring(replaceLen + 3, this.fieldValue.length) : 
        this.fieldValue;
    }
  }
}
</script>

<style scoped>

</style>